package com.example.demo6.common;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class Result<T> {

    private Integer code; //编码：200成功，500和其它数字为失败

    private String msg; //错误信息

    private T data; //数据

    //private Map map = new HashMap(); //动态数据

    public static <T> Result<T> success(T object,String msg) {
        Result<T> result = new Result<>();
        result.msg=msg;
        result.data = object;
        result.code = 200;
        return result;
    }

    public static <T> Result<T> error(String msg) {
        Result r = new Result();
        r.msg = msg;
        r.code = 500;
        return r;
    }

//    public Result<T> add(String key, Object value) {
//        this.map.put(key, value);
//        return this;
//    }

}
